package com.hfh.Thread;

public class InterruptDemo extends Thread {

    volatile boolean flag = true;

    @Override
    public void run() {
        while (flag) {
            System.out.println("run...");
        }
    }

    public static void main(String[] args) {
        InterruptDemo t = new InterruptDemo();
        t.start();

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        t.flag = false;
    }
}
